<template>
  <div class="app-container">
    <el-row>
      <el-col>
        <el-form
          :inline="true"
          :model="searchForm"
          ref="searchForm"
          size="small"
        >
          <el-form-item prop="name">
            <el-input v-model="searchForm.name" placeholder="名称"></el-input>
          </el-form-item>
          <el-form-item>
            <el-button type="primary" icon="el-icon-search">查询</el-button>
            <el-button type="success" icon="el-icon-plus">新增</el-button>
          </el-form-item>
        </el-form>
      </el-col>
    </el-row>
    <el-row>
      <el-col>
        <el-table
          :data="depts"
          style="width: 100%; margin-bottom: 20px"
          row-key="id"
          border
          default-expand-all
          :tree-props="{ children: 'children' }"
        >
          <el-table-column
            prop="id"
            label="ID"
            sortable
            align="center"
            width="100"
          >
          </el-table-column>
          <el-table-column prop="name" label="名称" align="center">
          </el-table-column>
          <el-table-column prop="parent.name" label="上级机构" align="center">
          </el-table-column>
          <el-table-column prop="" label="排序" align="center">
          </el-table-column>
          <el-table-column prop="createBy" label="创建人" align="center">
          </el-table-column>
          <el-table-column
            prop="createTime"
            label="创建时间"
            align="center"
            sortable
          >
          </el-table-column>
          <el-table-column width="190" label="操作">
            <template>
              <el-button icon="el-icon-edit" size="mini">编辑</el-button>
              <el-button icon="el-icon-delete" size="mini" type="danger"
                >删除</el-button
              >
            </template>
          </el-table-column>
        </el-table>
        <el-pagination
          style="float: right; margin-top: 10px"
          background
          layout="prev, pager, next"
          :hide-on-single-page="true"
        >
        </el-pagination>
      </el-col>
    </el-row>
  </div>
</template>

<script>
import http from "@/utils/request";
export default {
  mounted() {
    http.get(`/department`).then((res) => {
      this.depts = res.data.data;
      console.log(this.depts);
      this.depts.map((dept) => {});
      console.log(this.depts);
    });
  },
  data() {
    return {
      searchForm: {
        name: "",
      },
      depts: [],
    };
  },
};
</script>

<style></style>
